<template>
  <div class="body">

    <view class="page-top page-top2">
      <view class="jf-ye">
        <view><text>{{ score.score_num }}</text></view>
        <view><text>积分余额</text></view>
      </view>

      <view class="jf-dh">
        <view class="jf-dh-left">
          <image src="/static/images/a16.png"></image>
        </view>
        <view class="jf-dh-right">
          <view @click="toAccount"><text>管理兑换账户</text></view>
          <view><text>点击进入</text></view>
        </view>
        <div style="clear:both"></div>
      </view>
    </view>

    <view class="orderlist">
      <view class="jfdh-hcont">
        <view class="jftclist">
          <ul style="margin-bottom: 50px;">
            <li v-for="(item, index) in items"
                :key="index"
                :class="['klm',{active: isActive === index}]" @click="setActive(index)">{{ item }}</li>
            <div style="clear:both"></div>
          </ul>
          <button class="tjsq" @click="sub">提交申请</button>
        </view>
      </view>
    </view>

  </div>
</template>

<script>
// 例如：import uploadFile from '@/components/uploadFile/uploadFile'

import {changeScore, getUserScore} from "../../../../requests/merchant";

let $this
export default {
  name: '',
  // import引入的组件需要注入到对象中才能使用
  components: {},
  props: {
    // patientIn: {
    //   type: Object,
    //   default () {
    //     return {}
    //   }
    // }
  },
  data() {
    // 这里存放数据
    return {
      score: '',
      items: ['50积分', '100积分', '150积分','200积分'],
      isActive: 0,
      selectScore: '50'
    }
  },
  // 方法集合
  methods: {
    setActive(index) {
      this.isActive = index
      $this.selectScore = $this.items.index
    },
    toAccount() {
      mpvue.navigateTo({
        url: '/pages/merchant/score/account/main',
      })
    },
    sub() {
      let $data = {}
      $data.add_type = 2
      $data.num = $this.selectScore
      changeScore($data).then(res => {
        let resp = res.data
        if (resp.code === 0) {
        }
      })


    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    $this = this

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  onShow() {
    //获取总的积分
    getUserScore().then(res => {
      let resp = res.data
      if (resp.code === 0) {
        this.score = resp.data
      }
    })
  }
}
</script>

<style>
@import "index.css";
</style>
